<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>待办事项</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/xadmin.css">
    <script src="lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="createdate" placeholder="创建时间" id="createdate" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <select name="status">
                                <option value="-1">请选择</option>
                                <option value="0">未处理</option>
                                <option value="1">已处理</option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                <i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>

                <div class="layui-card-body ">
                    <table id="todolist" lay-filter="todolist"></table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    layui.use(['table', 'layer','laydate', 'form'],
        function () {
            var table = layui.table;
            var layer = layui.layer;
            var $ = layui.$;
            var laydate=layui.laydate;
            var form = layui.form;

            laydate.render({
                elem:"#createdate"
            })

            var user = JSON.parse(window.sessionStorage.getItem("user"));
            var id=user.id;
            //项目列表
            var tableIns = table.render({
                elem: '#todolist',
                url: 'todosBy',
                cellMinWidth: 95,
                page: true,
                height: "full-125",
                where: {"id": id},
                limit: 10,
                limits: [10, 15, 20, 25],
                id: "todoListTable",
                cols: [[
                    {field: 'eno', title: '设备编码', align: 'center'},
                    {field: 'createdate', title: '创建时间', align: 'center'},
                    {field: 'status', title: '是否处理', align: 'center',templet:function (obj) {
                            if(obj.status == 0)
                                return '未处理';
                            else
                                return '已处理';
                        }},
                    {field:'content',title:'维修内容', align: 'center'},
                    {field:'confirmdate',title:'完成时间', align: 'center'},
                    {field:'money',title:'维修费用', align: 'center'},
                    {title:'设备信息', align: 'center',templet:function (obj) {
                                        return "<i class='layui-icon layui-btn'style='font-size: 30px;' lay-event='equipmentInfo' title='设备信息'>&#xe60a;</i>"
                        }}
                ]]
            });
            //监听上面的搜索按钮事件
            form.on("submit(sreach)", function (data) {
                table.reload("todoListTable", {
                    page: {
                        curr: 1
                        //重新从第 1 页开始
                    },
                    where: data.field
                });
                return false;
            });

            table.on('tool(repair)', function (obj) {
                switch (obj.event) {
                    case 'repairManInfo':
                        xadmin.open("工程师信息", './repairmanInfo.html?' + obj.data.repairmanid, 600, 400);
                        break;
                    case 'equipmentInfo':
                        xadmin.open("设备信息", './equipmentInfo.html?' + obj.data.equipmentId, 600, 400);
                }
            })
        });</script>
</html>
